<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of FormHelper
 *
 * @author Zelic
 */
class Lib_Helper_FormHelper {
    static function startForm($data=null){
        $method = 'post';
        if (isset($data['method'])){
            $method = $data['method'];
        }
        if (isset($data['type'])&&$data['type']=='upload'){
            echo '<form action="'.$data['action'].'" method="'.$method.'" enctype="multipart/form-data">';
            if (isset($data['maxsize'])){
                echo '<input type="hidden">';
            }
        } else {
            echo '<form action="'.$data['action'].'" method="'.$method.'">';
        }
    }
    
    static function input($data){
        $field='';
        $class='';
        $type='input';
        $value='';
        if (isset($data['class'])){
            $class = $data['class'];
        }
        if (isset($data['field'])){
            $field = $data['field'];
        }
        if (isset($data['type'])){
            $type = $data['type'];
        }
        if (isset($data['value'])){
            $value = $data['value'];
        }
        
        echo '<input type="'.$type.'" id ="'.$field.'" name ="'.$field.'" class="'.$class.'" value="'.$value.'" />';
    }
    
    static function label($for, $title){
        echo '<label for="'.$for.'">'.$title.'</label>';
    }
    
    static function endForm(){
        echo '</form>';
    }
}

?>
